home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-GM / MPW / Scripts / Directory2 < prev    next >
Encoding:
Text File  |  1993-05-07  |  3.0 KB  |  70 lines  |  [TEXT/MPS ]

  1. #    File:    Directory2
  2. #
  3. #    Copyright Apple Computer, Inc. 1991
  4. #    All rights reserved.
  5. #
  6. #
  7. #        Scripts that have Projector commands within them can normally not be 
  8. #    executed by ToolServer. Using SourceServer, the RProj tool, and three support
  9. #    scripts (AliasSourceServer, UnaliasSourceServer, and Directory2), ToolServer
  10. #    can perform Projector functions. SourceServer must be running on the same
  11. #    computer as ToolServer before the Projector scripts can be executed.
  12. #    Individual Projector command lines are sent from ToolServer to SourceServer
  13. #    via AppleEvents by the RProj tool. To allow RProj to automatically be invoked
  14. #    any time a Projector command is encountered, we use the AliasSourceServer
  15. #    script to alias each ProjectorCommand to "RProj ProjectorCommand". To make
  16. #    sure that the aliases remain in effect even after the AliasSourceServer script
  17. #    has finished running, we must use the command line, "Execute AliasSourceServer".
  18. #    Directory commands also need to be aliased to Directory2, which will keep the
  19. #    current directory of both ToolServer and SourceServer set to the same location
  20. #    so both Projector and non-Projector commands operate on the same set of files.
  21. #    This alias is also established by the AliasSourceServer script. Finally, after
  22. #    completion of the Projector commands, "Execute UnaliasSourceServer" restores
  23. #    ToolServer to it's normal operation.
  24. #
  25. #        This file, Directory2, is one of the support scripts.
  26.  
  27. #        Prior to calling Directory2, the AliasSourceServer script has executed
  28. #    "Alias Directory Directory2". Within this script, we will use the built-in
  29. #    command, Directory, so we must unalias it to restore normal operation. The
  30. #    Unalias command has local scope, so upon exiting this script, the alias to
  31. #    Directory2 will be back in force!
  32.  
  33. Unalias Directory
  34.  
  35. #        The parameters for the original call to Directory remain the parameters
  36. #    for Directory2 also. We must now parse them and make sure the desired action
  37. #    takes place both for ToolServer and SourceServer:
  38.  
  39. if {#} == 0
  40.  
  41. #        "Directory", with no parameters, means to echo the current directory that
  42. #    the ToolServer script is executing in. For this we could just unalias directory
  43. #    and then make the call directly to the built in command. However, this is an
  44. #    opportunity to also insure that SourceServer is in synch with ToolServer. So 
  45. #    a variable is set to the current directory and then sent off as a command to
  46. #    SourceServer. Finally, the vanilla directory command is finished by echoing
  47. #    the current directory.
  48.  
  49.     Set myDir "`Directory`"
  50.     echo "{myDir}"
  51.     RProj Directory {myDir} ≥≥Dev:Null
  52. else
  53.     if "{1}" =~ /-q/
  54.  
  55. #        Sending "Directory -q" is a special beast. I can't send the unquoted
  56. #    directory name on to SourceServer because the RProj command will treat each
  57. #    word of the file name as a seperate argument. Just send the unquoted shell
  58. #    directory back to ToolServer.
  59.  
  60.         Directory "{1}"
  61.     else
  62.  
  63. #        The main operation of Directory2 is to SET the directory! Do this
  64. #    for both the Shell and SourceServer.
  65.  
  66.         Directory "{1}"
  67.         RProj Directory "{1}" ≥≥Dev:Null
  68.     end
  69. end
  70.